using System;
using System.Collections.Generic;
using ScrumManagementTool.domain.interfaces;

namespace ScrumManagementTool.domain
{
    public class UserStory : IUserStory
    {
        private int id;
        private string name;
        private string description;
        private int storyPoints;
        private int buisnessValue;
        private int priority;

        private IList<ITask> tasks = new List<ITask>();

        public int Id
        {
            get{ return id; }
            set{ id = value; }
        }

        public string Name
        {
            get { return name; }
            set { name = value; }
        }

        public string Description
        {
            get { return description; }
            set { description = value; }
        }

        public int StoryPoints
        {
            get { return storyPoints; }
            set { storyPoints = value; }
        }

        public int BuisnessValue
        {
            get { return buisnessValue; }
            set { buisnessValue = value; }
        }

        public int Priority
        {
            get { return priority; }
            set { priority = value; }
        }

        public IList<ITask> GetTasks()
        {
            return tasks;
        }

        public void SetTasks(IList<ITask> allTasks)
        {
            tasks = allTasks;
        }

        public void AddTask(ITask task)
        {
            tasks.Add(task);
        }

        public void RemoveTask(ITask task)
        {
            tasks.Remove(task);
        }

        public void RemoveTask(int taskId)
        {
            foreach (var task in tasks)
            {
                if (task.Id == taskId)
                    tasks.Remove(task);
            }
        }

        public int GetNumberOfTasks()
        {
            return tasks.Count;
        }
    }
}